<?php
class Xlog{
	var $i=0;
	var $max;
	var $data=array();
	
	function Xlog($max=100){
		$this->max = $max;
	}
	
	function set($key, $value){
		$this->i += 1;
		$key = date("H:i:s").' '.$key;
		$this->data[$key]=$value;
		/*
		if($this->i >= $this->max){
			$this->save();
		}
		*/
	}
	
	function clear(){
		$this->i = 0;
		$this->data=array();
	}
	
	function save(){
		$handle = fopen("log/".date("Ymd").".txt", "ab");
		if (!$handle){
			return false;
		}
		
		fwrite($handle, "\r\n".str_repeat('=', 100)."\r\n".print_r($this->data, true)."\r\n".str_repeat('=', 100));
		fclose($handle);
		$this->clear();
	}
}